{
  "nbformat": 4,
  "nbformat_minor": 0,
  "metadata": {
    "colab": {
      "provenance": []
    },
    "kernelspec": {
      "name": "python3",
      "display_name": "Python 3"
    },
    "language_info": {
      "name": "python"
    }
  },
  "cells": [
    {
      "cell_type": "markdown",
      "source": [
        "<a href=\"https://colab.research.google.com/drive/1vztM9vNv8IWWwPwonOO35VqNkJjktp4B?usp=sharing\" target=\"_parent\"><img src=\"https://colab.research.google.com/assets/colab-badge.svg\" alt=\"Open In Colab\"></a>\n",
        "\n",
        "### [CrewAI](https://docs.crewai.com/introduction) based Multi-Agentic system - AI Research Assistant\n",
        "\n",
        "This implementation uses CrewAI to create a powerful research system with three specialized agents working together to deliver comprehensive research reports:\n",
        "\n",
        "1. Research Analyst: Conducts thorough research on topics using Serper for web search\n",
        "2. Data Analyst: Analyzes findings to extract insights, patterns, and strategic recommendations\n",
        "3. Content Writer: Creates clear, engaging content in a professional business report format\n",
        "\n",
        "#### Setup\n",
        "1. Install required packages: `pip install crewai crewai_tools`\n",
        "2. Set your OpenAI API key (required)\n",
        "3. Set your Serper API key for web search capabilities\n",
        "\n",
        "#### Usage\n",
        "Configure your research by specifying topic, type (General/Market/Technical/Trend), depth level, and specific requirements. The system handles delegation between agents and delivers a structured final report with analysis and recommendations.\n",
        "\n",
        "Example: `run_research(specific_requirements=\"...\", research_topic=\"Impact of AI on Healthcare\", research_type=\"Market Analysis\")`"
      ],
      "metadata": {
        "id": "HxxOWz9dpsYj"
      }
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Install required libraries"
      ],
      "metadata": {
        "id": "Y3axTI0sp5Hg"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "!pip install -q -U crewai crewai_tools"
      ],
      "metadata": {
        "id": "ShxTNxM5gqtr",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "88c1a0eb-b911-4cd3-d59d-89cf6abfb3b7"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m42.5/42.5 kB\u001b[0m \u001b[31m2.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m67.3/67.3 kB\u001b[0m \u001b[31m4.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25h  Installing build dependencies ... \u001b[?25l\u001b[?25hdone\n",
            "  Getting requirements to build wheel ... \u001b[?25l\u001b[?25hdone\n",
            "  Preparing metadata (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
            "\u001b[2K     \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m48.2/48.2 kB\u001b[0m \u001b[31m3.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m240.2/240.2 kB\u001b[0m \u001b[31m11.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m6.7/6.7 MB\u001b[0m \u001b[31m50.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m545.9/545.9 kB\u001b[0m \u001b[31m27.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m134.0/134.0 kB\u001b[0m \u001b[31m9.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.4/2.4 MB\u001b[0m \u001b[31m62.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m147.8/147.8 kB\u001b[0m \u001b[31m9.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m211.4/211.4 kB\u001b[0m \u001b[31m14.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m628.3/628.3 kB\u001b[0m \u001b[31m28.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.4/71.4 kB\u001b[0m \u001b[31m5.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m32.3/32.3 MB\u001b[0m \u001b[31m32.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m38.4/38.4 MB\u001b[0m \u001b[31m18.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m65.0/65.0 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m55.9/55.9 kB\u001b[0m \u001b[31m3.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m118.7/118.7 kB\u001b[0m \u001b[31m8.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m177.4/177.4 kB\u001b[0m \u001b[31m8.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m59.5/59.5 kB\u001b[0m \u001b[31m3.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.6/5.6 MB\u001b[0m \u001b[31m33.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m5.7/5.7 MB\u001b[0m \u001b[31m43.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m57.6/57.6 kB\u001b[0m \u001b[31m3.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m756.0/756.0 kB\u001b[0m \u001b[31m32.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m236.0/236.0 kB\u001b[0m \u001b[31m13.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m16.4/16.4 MB\u001b[0m \u001b[31m33.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m233.6/233.6 kB\u001b[0m \u001b[31m11.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m278.6/278.6 kB\u001b[0m \u001b[31m11.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m252.9/252.9 kB\u001b[0m \u001b[31m10.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m94.8/94.8 kB\u001b[0m \u001b[31m5.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m131.6/131.6 kB\u001b[0m \u001b[31m5.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m76.4/76.4 kB\u001b[0m \u001b[31m5.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.0/2.0 MB\u001b[0m \u001b[31m41.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m45.1/45.1 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.5/2.5 MB\u001b[0m \u001b[31m58.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.9/50.9 kB\u001b[0m \u001b[31m2.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m311.8/311.8 kB\u001b[0m \u001b[31m17.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m94.6/94.6 kB\u001b[0m \u001b[31m6.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m101.6/101.6 kB\u001b[0m \u001b[31m6.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m13.3/13.3 MB\u001b[0m \u001b[31m12.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m74.7/74.7 kB\u001b[0m \u001b[31m4.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m300.7/300.7 kB\u001b[0m \u001b[31m15.1 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.9/2.9 MB\u001b[0m \u001b[31m47.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.1/71.1 kB\u001b[0m \u001b[31m4.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.1/1.1 MB\u001b[0m \u001b[31m37.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.0/3.0 MB\u001b[0m \u001b[31m27.8 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m62.3/62.3 kB\u001b[0m \u001b[31m3.6 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m3.3/3.3 MB\u001b[0m \u001b[31m33.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m459.8/459.8 kB\u001b[0m \u001b[31m17.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m1.6/1.6 MB\u001b[0m \u001b[31m33.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m209.2/209.2 kB\u001b[0m \u001b[31m9.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m319.7/319.7 kB\u001b[0m \u001b[31m14.4 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m508.0/508.0 kB\u001b[0m \u001b[31m15.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m306.6/306.6 kB\u001b[0m \u001b[31m6.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m71.5/71.5 kB\u001b[0m \u001b[31m3.7 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m4.0/4.0 MB\u001b[0m \u001b[31m44.5 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m452.6/452.6 kB\u001b[0m \u001b[31m18.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m46.0/46.0 kB\u001b[0m \u001b[31m2.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m78.5/78.5 kB\u001b[0m \u001b[31m3.9 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m2.5/2.5 MB\u001b[0m \u001b[31m28.2 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m86.8/86.8 kB\u001b[0m \u001b[31m3.3 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[2K   \u001b[90m━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━\u001b[0m \u001b[32m50.9/50.9 kB\u001b[0m \u001b[31m2.0 MB/s\u001b[0m eta \u001b[36m0:00:00\u001b[0m\n",
            "\u001b[?25h  Building wheel for pypika (pyproject.toml) ... \u001b[?25l\u001b[?25hdone\n",
            "\u001b[31mERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.\n",
            "transformers 4.48.3 requires tokenizers<0.22,>=0.21, but you have tokenizers 0.20.3 which is incompatible.\u001b[0m\u001b[31m\n",
            "\u001b[0m"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "### Import related libraries"
      ],
      "metadata": {
        "id": "9jJ1vqs-p_Zx"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "from crewai import Agent, Task, Crew, LLM\n",
        "from crewai_tools import SerperDevTool"
      ],
      "metadata": {
        "id": "RL-3LsYogoH5",
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "outputId": "01d8efb4-bd02-45de-ceda-cc474e9f1762"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "/usr/local/lib/python3.11/dist-packages/pydantic/_internal/_config.py:295: PydanticDeprecatedSince20: Support for class-based `config` is deprecated, use ConfigDict instead. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.10/migration/\n",
            "  warnings.warn(DEPRECATION_MESSAGE, DeprecationWarning)\n",
            "/usr/local/lib/python3.11/dist-packages/pydantic/_internal/_generate_schema.py:502: UserWarning: <built-in function callable> is not a Python type (it may be an instance of an object), Pydantic will allow any object with no validation since we cannot even enforce that the input is an instance of the given type. To get rid of this error wrap the type with `pydantic.SkipValidation`.\n",
            "  warn(\n",
            "/usr/local/lib/python3.11/dist-packages/crewai_tools/tools/scrapegraph_scrape_tool/scrapegraph_scrape_tool.py:34: PydanticDeprecatedSince20: Pydantic V1 style `@validator` validators are deprecated. You should migrate to Pydantic V2 style `@field_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.10/migration/\n",
            "  @validator(\"website_url\")\n",
            "/usr/local/lib/python3.11/dist-packages/crewai_tools/tools/selenium_scraping_tool/selenium_scraping_tool.py:26: PydanticDeprecatedSince20: Pydantic V1 style `@validator` validators are deprecated. You should migrate to Pydantic V2 style `@field_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.10/migration/\n",
            "  @validator(\"website_url\")\n",
            "/usr/local/lib/python3.11/dist-packages/crewai_tools/tools/vision_tool/vision_tool.py:15: PydanticDeprecatedSince20: Pydantic V1 style `@validator` validators are deprecated. You should migrate to Pydantic V2 style `@field_validator` validators, see the migration guide for more details. Deprecated in Pydantic V2.0 to be removed in V3.0. See Pydantic V2 Migration Guide at https://errors.pydantic.dev/2.10/migration/\n",
            "  @validator(\"image_path_url\")\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "import getpass\n",
        "import os"
      ],
      "metadata": {
        "id": "GT55z5AkhyOW"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "markdown",
      "source": [
        "#### Provide a OpenAI API key (Paid One)\n",
        "\n",
        "[OpenAI API Key Creation Link](https://platform.openai.com/api-keys)\n",
        "\n",
        "\n"
      ],
      "metadata": {
        "id": "F6UeDlrgqI2A"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "os.environ[\"OPENAI_API_KEY\"] = getpass.getpass()"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "yobvrD3glfd4",
        "outputId": "4acb0857-2ed6-4143-8088-e30dceb17604"
      },
      "execution_count": null,
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "··········\n"
          ]
        }
      ]
    },
    {
      "cell_type": "markdown",
      "source": [
        "#### Provide a Serper API key\n",
        "\n",
        "[Serper API Key Creation Link](https://serper.dev/api-key)"
      ],
      "metadata": {
        "id": "Us0IcAcx3t2a"
      }
    },
    {
      "cell_type": "code",
      "source": [
        "os.environ[\"SERPER_API_KEY\"] = getpass.getpass()"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "axt1yDZN3rK8",
        "outputId": "554eb85c-f5f7-4bfe-bf27-2e8b93561dca"
      },
      "execution_count": null,
      "outputs": [
        {
          "name": "stdout",
          "output_type": "stream",
          "text": [
            "··········\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [
        "def create_research_crew():\n",
        "    \"\"\"Create the research crew with agents\"\"\"\n",
        "\n",
        "    search_tool = SerperDevTool(\n",
        "        search_url=\"https://google.serper.dev/search\",\n",
        "        n_results=2,\n",
        "    )\n",
        "\n",
        "    researcher = Agent(\n",
        "        role='Research Analyst',\n",
        "        goal='Conduct thorough research on topics',\n",
        "        backstory='Expert researcher with years of experience',\n",
        "        verbose=False,\n",
        "        tools=[search_tool],\n",
        "        allow_delegation=True\n",
        "    )\n",
        "\n",
        "    analyst = Agent(\n",
        "        role='Data Analyst',\n",
        "        goal='Analyze findings and extract insights',\n",
        "        backstory='Experienced data analyst and interpreter',\n",
        "        verbose=False,\n",
        "        allow_delegation=True\n",
        "    )\n",
        "\n",
        "    writer = Agent(\n",
        "        role='Content Writer',\n",
        "        goal='Create clear, engaging content',\n",
        "        backstory='Professional technical writer',\n",
        "        verbose=False,\n",
        "        allow_delegation=True\n",
        "    )\n",
        "\n",
        "    return researcher, analyst, writer"
      ],
      "metadata": {
        "id": "EgNfNgxQz-1_"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "def create_tasks(researcher, analyst, writer, research_topic, research_type,\n",
        "                depth_level, requirements):\n",
        "    \"\"\"Create research tasks\"\"\"\n",
        "    tasks = [\n",
        "        Task(\n",
        "            description=f\"\"\"\n",
        "            Research the topic: {research_topic}\n",
        "            Type: {research_type}\n",
        "            Depth: {depth_level}\n",
        "            Requirements: {requirements}\n",
        "            \"\"\",\n",
        "            expected_output=\"\"\"A comprehensive research document containing:\n",
        "            - Detailed findings and discoveries\n",
        "            - Statistical data and trends\n",
        "            - Key stakeholder information\n",
        "            - Market/industry context\n",
        "            - Relevant sources and citations\"\"\",\n",
        "            agent=researcher\n",
        "        ),\n",
        "        Task(\n",
        "            description=f\"\"\"\n",
        "            Analyze the research findings with focus on:\n",
        "            1. Key patterns and trends\n",
        "            2. Impact assessment\n",
        "            3. Comparative analysis\n",
        "            4. Future projections\n",
        "            Depth Level: {depth_level}\n",
        "            \"\"\",\n",
        "            expected_output=\"\"\"An analytical report containing:\n",
        "            - Key trends and patterns identified\n",
        "            - Impact analysis and implications\n",
        "            - Data-driven insights\n",
        "            - Strategic recommendations\n",
        "            - Risk assessment\"\"\",\n",
        "            agent=analyst\n",
        "        ),\n",
        "        Task(\n",
        "            description=f\"\"\"\n",
        "            Create a comprehensive report synthesizing the research and analysis.\n",
        "            Research Type: {research_type}\n",
        "            Depth: {depth_level}\n",
        "            Format: Professional business report\n",
        "            \"\"\",\n",
        "            expected_output=\"\"\"A well-structured final report including:\n",
        "            - Executive summary\n",
        "            - Key findings and insights\n",
        "            - Detailed analysis\n",
        "            - Supporting data and visuals\n",
        "            - Conclusions and recommendations\n",
        "            - References and sources\"\"\",\n",
        "            agent=writer\n",
        "        )\n",
        "    ]\n",
        "    return tasks"
      ],
      "metadata": {
        "id": "9z2Qe-3f0CpI"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Default Research Values\n",
        "DEFAULT_RESEARCH_TOPIC = \"Cryptocurrency and DeFi Trends in Emerging Markets\"\n",
        "DEFAULT_REQUIREMENTS = \"\"\"1. Adoption rates in different regions\n",
        "2. Regulatory landscape\n",
        "3. Popular platforms and services\n",
        "4. Financial inclusion impact\n",
        "5. Market growth projections\"\"\"\n",
        "\n",
        "def run_research(\n",
        "    specific_requirements,\n",
        "    research_topic: str = DEFAULT_RESEARCH_TOPIC,\n",
        "    research_type: str = \"General Research\",\n",
        "    depth_level: str = \"Moderate\",\n",
        "\n",
        "):\n",
        "    \"\"\"\n",
        "    Run the research process with the specified parameters\n",
        "\n",
        "    Args:\n",
        "        research_topic (str): The topic to research\n",
        "        research_type (str): Type of research (General Research, Market Analysis, Technical Review, Trend Analysis)\n",
        "        depth_level (str): Depth of research (Basic, Moderate, Comprehensive, Expert)\n",
        "        specific_requirements (str): Specific requirements for the research\n",
        "\n",
        "    Returns:\n",
        "        str: The research results\n",
        "    \"\"\"\n",
        "    try:\n",
        "        print(\"Initializing research crew...\")\n",
        "        researcher, analyst, writer = create_research_crew()\n",
        "\n",
        "        tasks = create_tasks(\n",
        "            researcher, analyst, writer,\n",
        "            research_topic, research_type,\n",
        "            depth_level, specific_requirements\n",
        "        )\n",
        "\n",
        "        crew = Crew(\n",
        "            agents=[researcher, analyst, writer],\n",
        "            tasks=tasks,\n",
        "            verbose=False\n",
        "        )\n",
        "\n",
        "        print(\"Conducting research...\")\n",
        "        crew_result = crew.kickoff()\n",
        "        result = str(crew_result)\n",
        "\n",
        "        print(\"Research completed!\")\n",
        "        return result\n",
        "\n",
        "    except Exception as e:\n",
        "        print(f\"An error occurred: {str(e)}\")\n",
        "        print(\"Please check if all required API keys are correctly configured.\")\n",
        "        return None\n"
      ],
      "metadata": {
        "id": "TOX4BfM_0FWl"
      },
      "execution_count": null,
      "outputs": []
    },
    {
      "cell_type": "code",
      "source": [
        "# Set your API keys in environment variables or .env file first\n",
        "research_result = run_research(\n",
        "    specific_requirements='''\n",
        "    1. Current AI applications in healthcare\n",
        "    2. Market size and growth projections\n",
        "    3. Key players and technologies\n",
        "    4. Regulatory considerations\n",
        "    5. Implementation challenges\n",
        "    ''',\n",
        "    research_topic=\"Impact of AI on Healthcare in 2024\",\n",
        "    research_type=\"Market Analysis\",\n",
        "    depth_level=\"Comprehensive\",\n",
        ")\n",
        "\n",
        "print(research_result)"
      ],
      "metadata": {
        "colab": {
          "base_uri": "https://localhost:8080/"
        },
        "id": "m0cqOrnB0Wla",
        "outputId": "b94c8c16-2fd6-4fdd-e421-6211ab5bd131"
      },
      "execution_count": null,
      "outputs": [
        {
          "output_type": "stream",
          "name": "stderr",
          "text": [
            "WARNING:opentelemetry.trace:Overriding of current TracerProvider is not allowed\n"
          ]
        },
        {
          "output_type": "stream",
          "name": "stdout",
          "text": [
            "Initializing research crew...\n",
            "Conducting research...\n",
            "Research completed!\n",
            "# Comprehensive Market Analysis: The Impact of AI on Healthcare in 2024\n",
            "\n",
            "## Executive Summary\n",
            "As we enter 2024, Artificial Intelligence (AI) continues to revolutionize the healthcare landscape, enhancing patient care, streamlining operations, and driving innovative research. This analysis delves deep into the current applications of AI in healthcare, examining the market size, growth projections, key players, regulatory considerations, and implementation challenges faced by healthcare organizations.\n",
            "\n",
            "## 1. Current AI Applications in Healthcare\n",
            "AI technologies are being deployed across various sectors within healthcare. Some key applications include:\n",
            "\n",
            "### 1.1. Diagnostic Tools\n",
            "AI algorithms are widely used in diagnostic imaging, pathology, and genomics. For instance, platforms like Google's DeepMind have been deployed for early detection of diseases such as diabetic retinopathy and age-related macular degeneration.\n",
            "\n",
            "### 1.2. Predictive Analytics\n",
            "Predictive analytics tools are employed to forecast patient outcomes and optimize treatment plans. Companies like IBM Watson Health provide solutions to predict patient deterioration, enhancing proactive care.\n",
            "\n",
            "### 1.3. Personalized Medicine\n",
            "AI enables the analysis of genetic data and patient histories to tailor specific treatment regimens, improving treatment efficacy. This is evidenced in initiatives like Tempus, which leverages AI to provide personalized cancer care.\n",
            "\n",
            "### 1.4. Virtual Health Assistants\n",
            "AI-powered chatbots and virtual nurses, such as Babylon Health, are used for patient triage, answering health inquiries, and managing chronic conditions, improving patient engagement and access to care.\n",
            "\n",
            "## 2. Market Size and Growth Projections\n",
            "The global AI in healthcare market was valued at USD 6.6 billion in 2023 and is projected to reach USD 20.4 billion by 2028, growing at a compound annual growth rate (CAGR) of 25.9% (Source: MarketsandMarkets, 2023). Key factors driving this growth include:\n",
            "\n",
            "- Increased data generation from electronic health records (EHRs)\n",
            "- Advancements in AI technologies and machine learning algorithms\n",
            "- Pressure to reduce healthcare costs and improve patient outcomes\n",
            "\n",
            "### 2.1. Statistical Insights\n",
            "According to Statista, as of 2023, approximately 80% of healthcare executives believe that AI will significantly improve patient care quality within the next few years.\n",
            "\n",
            "## 3. Key Players and Technologies in the Market\n",
            "Several companies are leading the charge in AI healthcare innovations:\n",
            "\n",
            "### 3.1. Major Companies\n",
            "- **IBM Watson Health**: Focused on cognitive computing and data analysis to assist in personalized medicine.\n",
            "- **Siemens Healthineers**: Develops imaging systems enhanced with AI capabilities for diagnostics.\n",
            "- **Google Health**: Utilizing machine learning in various applications including imaging and electronic health analysis.\n",
            "- **Philips Healthcare**: Explores AI in radiology and sleep technologies.\n",
            "\n",
            "### 3.2. Emerging Technologies\n",
            "- **Natural Language Processing (NLP)**: Enhances EHR usability by streamlining clinician documentation.\n",
            "- **Machine Learning**: Improves predictive analytics and diagnostic precision in clinical settings.\n",
            "\n",
            "## 4. Regulatory Considerations\n",
            "The deployment of AI in healthcare is influenced by various regulatory bodies, primarily:\n",
            "\n",
            "### 4.1. FDA Regulations\n",
            "The Food and Drug Administration (FDA) is actively reviewing AI-based tools for diagnostic and therapeutic applications. Key initiatives include:\n",
            "- Guidelines on software as a medical device (SaMD)\n",
            "- A fast-track process for AI tools which demonstrate significant advancement in healthcare.\n",
            "\n",
            "### 4.2. Data Privacy Laws\n",
            "Compliance with regulations such as HIPAA in the U.S. and GDPR in Europe is paramount, ensuring patient data privacy and security in AI systems.\n",
            "\n",
            "## 5. Implementation Challenges\n",
            "Despite the promising potential of AI, organizations face multiple implementation hurdles:\n",
            "\n",
            "### 5.1. Data Quality and Integration\n",
            "Healthcare providers often struggle with disparate data systems, making it challenging to integrate AI solutions effectively.\n",
            "\n",
            "### 5.2. Resistance to Change\n",
            "Cultural resistance within organizations can impede the adoption of AI technologies. Education and clear communication regarding AI benefits are essential to mitigate this issue.\n",
            "\n",
            "### 5.3. Ethical and Bias Concerns\n",
            "AI algorithms can be susceptible to bias if not properly vetted, leading to inequitable healthcare outcomes. Continuous monitoring and recalibrating of algorithms are crucial to address these concerns.\n",
            "\n",
            "## Conclusion\n",
            "The AI healthcare market is poised for explosive growth and transformative change in 2024. However, to harness AI's full potential, stakeholders must navigate regulatory landscapes, tackle implementation challenges, and ensure ethical considerations are at the forefront. The future of healthcare will be significantly shaped by AI technologies, driving enhanced patient outcomes and operational efficiencies.\n",
            "\n",
            "### References\n",
            "1. MarketsandMarkets. (2023). AI in Healthcare Market - Global Forecast to 2028.\n",
            "2. Statista. (2023). Expected Impact of AI on Patient Care Quality.\n",
            "3. FDA. (2023). Digital Health Center of Excellence.\n",
            "```\n"
          ]
        }
      ]
    },
    {
      "cell_type": "code",
      "source": [],
      "metadata": {
        "id": "xcDytzbM25RQ"
      },
      "execution_count": null,
      "outputs": []
    }
  ]
}